package com.tiancheng.trade.order.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tiancheng.trade.commom.core.data.PageInfo;

public interface TYBaseMapper<T> extends BaseMapper<T> {

	/**
	 * 分页查询
	 * @param var2
	 * @param page
	 * @param limit
	 * @return
	 */
	default PageInfo<T> find(Wrapper<T> var2, int page, int limit) {
		IPage<T> pageResult = this.selectPage(new Page<>(page, limit), var2);
		PageInfo.Pagination pagination = new PageInfo.Pagination(pageResult.getCurrent(), (int) pageResult.getSize(),
				pageResult.getTotal());
		return new PageInfo<>(pageResult.getRecords(), pagination);
	}
}
